import { INDEXC0LUMNS, C0LUMNS, INVENTORY_COORDINATION } from './index.const';
import ElEditable from '@components/el-editable';
import { IndexService } from './index.service';
const indexService = new IndexService();
export default {
  components: {
    ElEditable
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      columns: C0LUMNS,
      consigneeInfo: {},
      dialogVisible: false,
      orderDetail: {},
      orderId: '',
      busModel: 1,
      activeIndex: 0,
      inventoryInfoColumns: INVENTORY_COORDINATION,
      inventoryInfo: [
        {
          productName: '中空接骨螺钉-102',
          productCode: '123',
          serialNumber: '1',
          batchNo: '17018900',
          registCode: '1',
          stockCount: '1',
          productValidDate: '2021-11',
          updatedAt: '2020-3-4'
        },
        {
          productName: '定制式活动义齿',
          productCode: '123',
          serialNumber: '1',
          batchNo: '17018900',
          registCode: '1',
          stockCount: '1',
          productValidDate: '2021-11',
          updatedAt: '2020-3-4'
        },
        {
          productName: '介入人工生物心脏瓣膜 经心尖介',
          productCode: '123',
          serialNumber: '1',
          batchNo: '17018900',
          registCode: '1',
          stockCount: '1',
          productValidDate: '2021-11',
          updatedAt: '2020-3-4'
        }
      ],
      order_tab: [
        { title: '附加信息', columns: [], tabData: [] },
        { title: '序列号信息', columns: INDEXC0LUMNS, tabData: [] }
      ],
      payload: [
        {
          productName: '预弯棒，4.75x30',
          productCode: 'MT1475501030',
          unit: '根',
          barCode: '0080670W',
          inDate: '2022-12-31',
          productPrice: '0',
          productCount: '',
          hospital: '北京朝阳医院',
          doctor: '刘平'
        },
        {
          productName: '预弯棒，4.75x30',
          productCode: 'MT1475501030',
          unit: '根',
          barCode: '0080670W',
          inDate: '2022-12-31',
          productPrice: '0',
          productCount: '',
          hospital: '北京朝阳医院',
          doctor: '刘平'
        }
      ],
      appendRelateOrder: []
    };
  },
  async created() {
    this.orderId = this.$route.query.id;
    //根据id获取列表详情
    const detail = await this.apiMMallWeb.OrderDetailOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    indexService.getTransportName(detail);
    this.orderDetail = detail;
    //获取附加信息
    const data = await this.apiMMallWeb.AppendRelateOrderV1ApiPOST({
      form: { busModel: this.busModel, productLineCode: this.orderDetail.productLineCode }
    });
    this.appendRelateOrder = data;
    //库存配位
    const res = await this.apiMMallWeb.PageListStockBatchOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    this.order_tab[0].tabData = res.content;
    //收货人信息
    const consigneeInfo = await this.apiMMallWeb.OrderReceiverOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    this.consigneeInfo = consigneeInfo;
    //订单详情采购产品分页列表
    const pruduct = await this.apiMMallWeb.PageListOrderDetailProductOrderV1ApiPOST({
      query: {
        orderDetailId: this.orderDetail.orderDetailId,
        page: 0,
        pageSize: 0
      }
    });
    // this.payload = pruduct.content;
  },
  methods: {
    //添加高亮
    tableRowClassName({ row }) {
      if (row.orderCount > row.inventoryCount) {
        return 'bgHeight';
      }
    },
    showLog() {
      this.dialogVisible = true;
    },
    changeIndex(index) {
      this.activeIndex = index;
    },
    back() {
      this.$router.go(-1);
    }
  }
};
